package 模拟斗地主;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

public class PokerDemo {
    public static void main(String[] args) {
        ArrayList<String>array=new ArrayList<String>();
        //定义花色数组
        String[]colors={"♦","♠","♥","♣"};
        //定义点数数组
        String[]numbers={"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
        for (String color:colors){
            for (String number:numbers){
                array.add(color+number);
            }
        }
        array.add("小王");
        array.add("大王");
        //洗牌，把牌打散
        Collections.shuffle(array);
        //发牌，也就是遍历集合，给三个玩家发牌
        ArrayList<String>shqArray=new ArrayList<String>();
        ArrayList<String>jyyArray=new ArrayList<String>();
        ArrayList<String>zpArray=new ArrayList<String>();
        ArrayList<String>dpArray=new ArrayList<String>();
        for (int i=0;i<array.size();i++){
            String poker = array.get(i);
            if (i>= array.size()-3){
                dpArray.add(poker);
            }else if (i%3==0){
                shqArray.add(poker);
            }else if (i%3==1){
                jyyArray.add(poker);
            }else if (i%3==2){
                zpArray.add(poker);
            }
        }
        //看牌，也就是三个玩家分别遍历自己的牌
        lookPoker("shihaoqing",shqArray);
        lookPoker("jiayueyue",jyyArray);
        lookPoker("zhangpeng",zpArray);
        lookPoker("dipai",dpArray);
    }

    //看牌的方法
    public static void lookPoker(String name,ArrayList<String>array){
        System.out.print(name+"的牌是：");
        for (String poker:array){
            System.out.print(poker+" ");
        }
        System.out.println();
    }
}
